﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using WindowsFormsApplication9.weather;
using WindowsFormsApplication9.stock;

namespace WindowsFormsApplication9
{
    public partial class Form1 : Form
    {

        weather.GlobalWeather w = new GlobalWeather();

        stock.StockQuote st = new StockQuote();

        public Form1()
        {
            InitializeComponent();
        }

        private void btnGetCities_Click(object sender, EventArgs e)
        {

            string results = w.GetCitiesByCountry(textBox1.Text);

            XmlDocument WeatherXML = new XmlDocument();
            WeatherXML.LoadXml(results);

            XmlNodeReader XMLReader = new XmlNodeReader(WeatherXML);

            DataSet DS = new DataSet();
            DS.ReadXml(XMLReader);


            foreach (DataRow DR in DS.Tables[0].Rows)
            {
                listBox1.Items.Add(DR[1].ToString());
            }
        }

        private void btnStock_Click(object sender, EventArgs e)
        {
            textBox3.Text = st.GetQuote(textBox2.Text);
        }
    }
}
